﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using U9API.Pub;

namespace U9API.Controllers
{
    public class CustomerController : BaseController
    {
        // GET: MaterialOut
        public ActionResult Index()
        {
            return View();
        }
        [System.Web.Mvc.HttpPost]
        public String Create()
        {
            JsonModel.APIResponse result = new JsonModel.APIResponse();
            String data = String.Empty;
            try
            {
                APIRequest request = new APIRequest(this.HttpContext);
                data = request.data;
                JsonModel.ApiQuery model = Common.FromJson<JsonModel.ApiQuery>(request.data);
                U9API.APIHelper.CustomerHelper helper = new APIHelper.CustomerHelper();
                if (request.operation == 0)
                {
                    helper.Create(helper.U9Constr, request.operation, model);
                }
             
                result.SetSuccessed(helper.result); 
            }
            catch (Exception ex)
            {
                Pub.WriteLog.WriteLine("CustomerController", "Create", ex);
                Pub.WriteLog.WriteLine(data);
                result.SetError(ex.Message);
            }
            return result.ToJson();
        }
    }
}